<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
 lang="en" dir="ltr">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="../codebase/default.css" type="text/css" media="screen" title="no title" charset="utf-8"><title>
    dhtmlxconnector:initialization_of_dhtmlxconnector    [DHX documentation]
  </title></head>

<body>
<div class="dokuwiki">
  
  <div class="stylehead">

    <div class="header">
    <a class="logo" href="http://dhtmlx.com" title="DHTMLX Home Page"></a>
    <span class="tittle-dhtmlx">DHTMLX Docs & Samples Explorer</span>

    <div class="search-field">
        <form action="/dhtmlx/docs/doku.php" accept-charset="utf-8" id="dw__search"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" title="Search" /><button type="submit"></button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form>    </div>
        <div class="buttons">
                <a class="doc"></a>
                <a title="DHTMLX Samples homepage" href="../samples.html" class="sample"/></a>
        </div>
     <!-- <div class="pagename">
        [[<a href="#"  title="Backlinks">dhtmlxconnector:initialization_of_dhtmlxconnector</a>]]
      </div>
      <div class="logo">
        <a href="/dhtmlx/docs/doku.php"  name="dokuwiki__top" id="dokuwiki__top" accesskey="h" title="[H]">DHX documentation</a>      </div>

      <div class="clearer"></div>-->
        
    </div>

    
<!--   <div class="bar" id="bar__top">
      <div class="bar-left" id="bar__topleft">
        <form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>        <form class="button btn_revs" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="revisions" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Old revisions" class="button" accesskey="o" title="Old revisions [O]" /></div></form>      </div>

      <div class="bar-right" id="bar__topright">
        <form class="button btn_recent" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="recent" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Recent changes" class="button" accesskey="r" title="Recent changes [R]" /></div></form>        <form action="/dhtmlx/docs/doku.php" accept-charset="utf-8" id="dw__search"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" title="Search" /><button type="submit"></button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form>&nbsp;
      </div>

      <div class="clearer"></div>
    </div> -->

<!--        <div class="breadcrumbs">
      <span class="bchead">Trace:</span> <span class="bcsep">&raquo;</span> <span class="curid"><a href="/dhtmlx/docs/doku.php?id=dhtmlxconnector:initialization_of_dhtmlxconnector"  class="breadcrumbs" title="dhtmlxconnector:initialization_of_dhtmlxconnector">initialization_of_dhtmlxconnector</a></span>    </div>
    -->

    
  </div>
  
  
  <div class="page">
    <!-- wikipage start -->
    <!-- TOC START -->
<div class="toc">
<div class="tocheader toctoggle" id="toc__header">Table of Contents</div>
<div id="toc__inside">

<ul class="toc">
<li class="clear">

<ul class="toc">
<li class="level2"><div class="li"><span class="li"><a href="#initialization_of_dhtmlxconnector" class="toc">Initialization of dhtmlxConnector</a></span></div>
<ul class="toc">
<li class="level3"><div class="li"><span class="li"><a href="#client_side_code" class="toc">Client Side Code</a></span></div></li>
<li class="level3"><div class="li"><span class="li"><a href="#server_side_code" class="toc">Server Side Code</a></span></div></li></ul>
</li></ul>
</li></ul>
</div>
</div>
<!-- TOC END -->

<p>
<div class='backlinks'><div class='backlink last_backlink'><img src="icons___file.gif"  class="media" alt="" /><a href="../index.html" class="wikilink1" title="start">Index</a></div><div class='arrow'></div><div class='backlink last_backlink'><img src="icons___connector.gif"  class="media" alt="" /><a href="index.html" class="wikilink1" title="dhtmlxconnector:toc">dhtmlxconnector</a></div><div class='arrow'></div><div class='backlink'><a href="dhtmlxconnector___toc_what_is_dhtmlxconnector.html" class="wikilink1" title="dhtmlxconnector:toc_what_is_dhtmlxconnector">Usage Guide</a></div></div>

</p>

<h2><a name="initialization_of_dhtmlxconnector" id="initialization_of_dhtmlxconnector">Initialization of dhtmlxConnector</a></h2>
<div class="level2">

</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="98-147" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Edit" class="button" title="Initialization of dhtmlxConnector" /></div></form></div>
<h3><a name="client_side_code" id="client_side_code">Client Side Code</a></h3>
<div class="level3">

<p>
No modifications on client side are required for regular data loading. In other cases you should include the connector.js file (located in dhtmlxConnector_php/codebase) into your page. To perform any update operations you have to use dhtmlxDataProcessor, which has been already included in both Professional and Standard editions of dhtmlx library. 
</p>

<p>
For data loading you need to point load (or loadXML) method of dhtmlx component to connector file:
</p>
<pre class="code javascript">        myGrid <span class="sy0">=</span> <span class="kw2">new</span> dhtmlXGridObject<span class="br0">&#40;</span><span class="st0">&quot;pObjId&quot;</span><span class="br0">&#41;</span>;
        <span class="co1">//... grid configuration commands</span>
        myGrid.<span class="me1">load</span><span class="br0">&#40;</span><span class="st0">&quot;myconnector.php&quot;</span><span class="br0">&#41;</span>;</pre>
<p>

To perform insert/update/delete operations you should add dhtmlxDataProcessor (for more details about dhtmlxDataProcessor see related documentation) and use connector file as parameter of constructor
</p>
<pre class="code javascript">        myDP <span class="sy0">=</span> <span class="kw2">new</span> dataProcessor<span class="br0">&#40;</span><span class="st0">&quot;myconnector.php&quot;</span><span class="br0">&#41;</span>;
        myDP.<span class="me1">init</span><span class="br0">&#40;</span>myGrid<span class="br0">&#41;</span>;
&nbsp;</pre>
<p>
<a href="dhtmlxconnector___client_side_other_components.html" class="wikilink1" title="dhtmlxconnector:client_side_other_components">Samples of client side initialization for other components</a>
</p>

</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="148-1193" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Edit" class="button" title="Client Side Code" /></div></form></div>
<h3><a name="server_side_code" id="server_side_code">Server Side Code</a></h3>
<div class="level3">

<p>
To start operating with dhtmlxConnector  you should do the following:

</p>
<ul>
<li class="level1"><div class="li">  include appropriate connector file into the page (Here and after we&#039;ll use dhtmlxGrid connector for code samples. All differences between connectors of other components will be described additionally. When using sample code with appropriate components, all files or function names which contain component name “grid” should be changed to “tree”, “treegrid” or “combo” accordingly.)</div>
</li>
</ul>
<pre class="code php">	<span class="kw1">require</span><span class="br0">&#40;</span><span class="st0">&quot;connector/grid_connector.php&quot;</span><span class="br0">&#41;</span>;</pre><ul>
<li class="level1"><div class="li">   create Database connection </div>
</li>
</ul>
<pre class="code php">        <span class="re0">$res</span><span class="sy0">=</span><a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span><span class="sy0">,</span><span class="st0">&quot;root&quot;</span><span class="sy0">,</span><span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;
        <a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&quot;myDatabase&quot;</span><span class="br0">&#41;</span>;</pre>
<p>

After have implemented these operations you are ready to instantiate connector object. The only database connection link variable is mandatory parameter in all constructors.  Optionally, you can specify database type (“MySQL” by default. Other possible: “Postgre”)
</p>
<pre class="code php">       <span class="re0">$gridConn</span> <span class="sy0">=</span> <span class="kw2">new</span> GridConnector<span class="br0">&#40;</span><span class="re0">$res</span><span class="sy0">,</span><span class="st0">&quot;MySQL&quot;</span><span class="br0">&#41;</span>;</pre>
<p>
And as a last step - <a href="dhtmlxconnector___loading_editing_data.html" class="wikilink1" title="dhtmlxconnector:loading_editing_data">configuration</a>, which fields and data will be used in connector

</p>
<pre class="code php">        <span class="re0">$gridConn</span><span class="sy0">-&gt;</span><span class="me1">render_table</span><span class="br0">&#40;</span><span class="st0">&quot;mytable&quot;</span><span class="sy0">,</span><span class="st0">&quot;item_id&quot;</span><span class="sy0">,</span><span class="st0">&quot;item_nm,item_cd&quot;</span><span class="br0">&#41;</span>;</pre>
<p>
This is all.
</p>

<p>
Above code must be enough to show data in component and sync update|delete|create operations from the component to the DB.
</p>

<p>
<a href="dhtmlxconnector___server_side_others.html" class="wikilink1" title="dhtmlxconnector:server_side_others">Server side initialization for other components and DB types</a>
</p>

</div>
<div class="secedit"><form class="button btn_secedit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="lines" value="1194-" /><input type="hidden" name="rev" value="1279031279" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Edit" class="button" title="Server Side Code" /></div></form></div>
    <!-- wikipage stop -->
  </div>

  <div class="clearer">&nbsp;</div>

  
  <div class="stylefoot">

    <div class="meta">
      <div class="user">
              </div>
     <!-- <div class="doc">
        dhtmlxconnector/initialization_of_dhtmlxconnector.txt &middot; Last modified: 2010/07/13 17:27 (external edit)      </div>
    </div>-->

   
    <!--<div class="bar" id="bar__bottom">-->
      <!--<div class="bar-left" id="bar__bottomleft">-->
        <!--<form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>-->
        <!--<form class="button btn_revs" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="revisions" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Old revisions" class="button" accesskey="o" title="Old revisions [O]" /></div></form>-->
      <!--</div>-->
      <!--<div class="bar-right" id="bar__bottomright">-->
        <!---->
        <!---->
        <!---->
        <!---->
        <!---->
        <!--<form class="button btn_index" method="get" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="index" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Index" class="button" accesskey="x" title="Index [X]" /></div></form>-->
        <!--<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="Back to top" onclick="window.scrollTo(0, 0)" title="Back to top" /></a>&nbsp;-->
      <!--</div>-->
      <!--<div class="clearer"></div>-->
    <!--</div>-->

  </div>

  

</div>

<div class="footerinc">


</div>

<div class="no"><img src="/dhtmlx/docs/lib/exe/indexer.php?id=dhtmlxconnector%3Ainitialization_of_dhtmlxconnector&amp;1279804813" width="1" height="1" alt=""  /></div>
     <div class="footer">
        <div class="footer-logo"></div>
        <div class="copyright">Copyright © 1998-2009 DHTMLX LTD.<br />All rights reserved.</div>
        <form class="button btn_edit" method="post" action="/dhtmlx/docs/doku.php"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="" /><input type="hidden" name="id" value="dhtmlxconnector:initialization_of_dhtmlxconnector" /><input type="submit" value="Edit this page" class="button" accesskey="e" title="Edit this page [E]" /></div></form>    	    </div>
</body>
</html>
